package com.itheima.service.impl;

import com.itheima.controller.PageResult;
import com.itheima.dao.UserDao;
import com.itheima.domain.Department;
import com.itheima.domain.Patient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LiuJie
 * 我亦无他,唯手熟尔
 */

@Service
public class UserServiceImpl implements com.itheima.service.UserService {
    @Autowired
    UserDao userDao;

    @Override
    public List<Department> queryDepartment() {
        List<Department> list = userDao.queryDepartment();
        return list;
    }

    @Override
    public Boolean addPatient(Patient patient) {
        Boolean flag = userDao.addPatient(patient);
        return flag;
    }

    @Override
    public PageResult queryPatientByName(Integer pageNum, Integer pageSize, String patientName) {
        long total = userDao.countAllPatientByName(patientName);
        List<Patient> list = userDao.queryPatientByName(pageNum, pageSize, patientName);
        for (Patient patient : list) {
            System.out.println(patient);
        }
        return new PageResult(total, list);
    }

    @Override
    public PageResult queryPatientByPage(Integer pageNum, Integer pageSize) {
        long total = userDao.countAllPatient();
        List<Patient> list = userDao.queryPatientByPage(pageNum, pageSize);
        for (Patient patient : list) {
            System.out.println(patient);
        }
        return new PageResult(total, list);
    }
}
